<?php
header("Content-type: text/html; charset=utf-8");
include_once '../dao/InvitationDao.class.php';
include_once '../dao/UserDao.class.php'; 
class InvitationService {
	
	private $invitationDao;
	private $userDao;
	
	public function InvitationService() {
		$this->invitationDao = new InvitationDao();
		$this->userDao = new UserDao();
	}
	
	/**
	 * 
	 * @param unknown $content 需求内容
	 * @param unknown $address  地址
	 * @param unknown $cate  类别
	 * @param unknown $posttime 发帖时间
	 * @param unknown $starttime 开始时间
	 * @param unknown $endtime 结束时间
	 * @param unknown $money 金额
	 * @param unknown $long 经度
	 * @param unknown $lati 纬度
	 */
	public function post($username,$content,$address,$cate,
			$posttime,$starttime,$endtime,$money,$long,$lati) {
		return $this->invitationDao->post($this->userDao->selectUserIDByUsername($username), $content, $address, $cate, $posttime,
				 $starttime, $endtime, $money, $long, $lati);
	}
	
	/**
	 * 按照发帖时间降序查询帖子 每次偏移5条
	 * @param unknown $rows : 从$rows行开始查询数据
	 */
	public function selectPostByPostTime($rows) {
		return	$this->invitationDao->selectPostByPostTime($rows);
	}
	
	/**
	 * 按照发帖金额降序查询帖子 每次偏移5条
	 * @param unknown $rows : 从$rows行开始查询数据
	 */
	public function  selectPostByMoney($rows) {
		return $this->invitationDao->selectPostByMoney($rows);
	}
	

	/**
	 * 根据榜单的ID修改榜单的状态
	 * @param unknown $id
	 * @return number
	 */
	public function updatePostStatusById($id,$aid) {
		return  $this->invitationDao->updatePostStatusById($id,$aid);
	}
	
	
	public function getUserEmailByPostId($id) {
		return $this->invitationDao->getUserEmailByPostId($id);
	}
	
	public function selectPostByAcceptId($id) {
		return $this->invitationDao->selectPostByAcceptId($id);
	}
	
	public function selectPostByPostId($id) { 
		return $this->invitationDao->selectPostByPostId($id);
	}
	
	
	
}